<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection" />
		<meta content="emai=no" name="format-detection" />
		<link rel="stylesheet" type="text/css" href="/wc/css/common.css" />
		<link rel="stylesheet" type="text/css" href="/wc/css/form.css" />
		<link rel="stylesheet" type="text/css" href="/wc/css/apply.css" />
		<script type="text/javascript" src="/wc/js/jquery-1.11.2.min.js"></script>
		<script type="text/javascript" src="/wc/js/underscore.js"></script>
		<script type="text/javascript" src="/wc/js/pinchzoom.js"></script>
		<title>芝士妈妈在线</title>
	</head>

	<body>
		<div class="wrapper">
			<form action="/doctor/inter" method="post">
				<h2>账号登录</h2>
				<section class="flex-wrapper flex-align-center">
					<label>手机号：</label>
					<p class="flex-1">
						<input type="tel" maxlength="13" id="mobile" name="mobile" value="" data-message="请输入手机号！" />
					</p>
				</section>
				<section class="flex-wrapper flex-align-center">
					<label>验证码：</label>
					<p class="flex-1">
						<input type="number" maxlength="8" id="code" name="code" value="" placeholder="" data-message="请输入验证码！" />
						<button type="button" id="geticode" class="special">获取验证码</button>
					</p>
				</section>
				<button type="button" id="btn_s" class="btn btn-red">登 录</button>
			</form>
		</div>
		<div class="hide popup-map">
			<div class="pinch-zoom">
				<img src="/wc/img/map.jpg" alt="" />
			</div>
		</div>
		<script src="/wc/js/common.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function() {
				var enalbeGeticode = true;

				if($('#geticode').length > 0) {
					$('#geticode').click(function(e) {
						zsmm.isValidated = true;
						validateInput("mobile");
						validatePhone("mobile");
						if(!zsmm.isValidated) {
							return false;
						}
						var phone = $.trim($('input[name="mobile"]').eq(0).val());
						if(enalbeGeticode) {
							enalbeGeticode = false;
							var i = 60;
							var obj = $(this);
							obj.text(i + '秒后重试').addClass('disabled');
							var intval = setInterval(function() {
								i -= 1;
								obj.text(i + '秒后重试');
								if(i <= 0) {
									clearInterval(intval);
									obj.text('获取短信验证码').removeClass('disabled');
									enalbeGeticode = true;
									return;
								}
							}, 1000);
							$.ajax({
								url: "/doctor/send",
								type: "get",
								dataType: "json",
								data: {
									mobile: phone
								},
								success: function(res) {
									zsmm.Toast.New(res.msg);
								}
							});
						}
					});
				}
				$("#btn_s").click(function(e) {
					e.preventDefault();
					zsmm.isValidated = true;
					var phone = $.trim($('input[name="mobile"]').eq(0).val());
					var code = $.trim($('input[name="code"]').eq(0).val());
					validateInput("code");
					//ajax校验验证码
					$.ajax({
						url: "/doctor/validcode",
						type: "get",
						dataType: "json",
						data: {
							mobile: phone,
							code: code
						},
						success: function(res) {
							if(res.error == 0) {
								$("form").submit();
							} else {
								zsmm.Toast.New(res.msg);
							}
						}
					});
				});
			});
		</script>
	</body>
</html>